package flyweightpattern;/*
 * @auther 顶风少年
 * @mail dfsn19970313@foxmail.com
 * @date 2019-08-02 21:47
 * @notify
 * @version 1.0
 */

import java.util.HashMap;

public class FlyweightFactory {
    private HashMap<Character, Flyweight> files = new HashMap();
    private Flyweight lnkFlyweight;

    public FlyweightFactory() {
    }

    public Flyweight factory(Character state) {
        if (files.containsKey(state)) {
            return files.get(state);
        } else {
            Flyweight fly = new ConcreteFlyweight(state);
            files.put(state, fly);
            return fly;
        }
    }
}
